
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ajax封装</title>
    <script src="/js/cn.ecut.myAjax.js"></script>
</head>
<body>

    <div id="name"></div>
    <div id="password"></div>
    <script type="text/javascript">
        let fn = function( o ){
            if ( o.currentTarget.readyState == 4  ){
                let x = JSON.parse( o.currentTarget.responseText ) ;
                document.querySelector("#name").innerHTML = x.data.name;
                document.querySelector("#password").innerHTML = x.data.password;
            }
        }
        let data = "username=zhangsanfeng&password=123";
        myAjax( "post" , "${pageContext.request.contextPath}/ajax" , fn , data ) ;
    </script>

</body>
</html>
